home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / libs / libc-4.6 / libc-4 / libc-4.6.27-syslog-fix / README
Encoding:
Text File  |  1995-09-06  |  3.0 KB  |  104 lines

  1. This archive contains a binary copy of Linux LIBC 4.6.27 with syslog.c fixed to
  2. correct the recent security hole that has been widely discussed.  The source
  3. patch is shown below.  In addition to this change, this C library already has
  4. the change:
  5.  
  6. #define _PATH_UTMP    "/var/run/utmp"
  7. #define _PATH_WTMP    "/var/log/wtmp"
  8. #define _PATH_LASTLOG    "/var/log/lastlog"
  9.  
  10. installed, which wasn't made until later revisions of the C library.  I already
  11. made this transition myself to make life easier later on.  From the more recent
  12. LIBC instructions, the following procedure should be performed to make the
  13. environment compatible with this library:
  14.  
  15. 1. lastlog, utmp and wtmp have been moved again by the Linux FS
  16.    standard, the transition procedure is like this:
  17.  
  18.    a. If /var/log doesn't exist,
  19.  
  20.     cd /var; mv adm log; ln -s /var/log adm
  21.     cd /var/log; mv utmp /var/run; ln -s /var/run/utmp .
  22.  
  23.    b. If /var/log exists,
  24.  
  25.     cd /var; mv adm/* log; rm -rf adm; ln -s /var/log adm
  26.     cd /var/log; mv utmp /var/run; ln -s /var/run/utmp .
  27.  
  28. When I announced that I'd fixed my own copy of 4.6.27, several people asked for
  29. a copy, so I am making these binaries available for those who do not yet wish
  30. to upgrade from 4.6.27, and also are not interested in compiling their own copy
  31. from source.  It was compiled using GCC 2.7.0.  Installation can be completed
  32. by extracting the files and moving them into place.  Be careful when installing
  33. files into /lib, as an error can leave a non-working system.
  34.  
  35.         Leonard
  36.  
  37.  
  38. --- syslog.c-    Tue Aug 23 14:14:41 1994
  39. +++ syslog.c    Thu Aug 31 23:53:27 1995
  40. @@ -102,7 +102,9 @@
  41.      register char *p;
  42.      time_t now;
  43.      int fd, saved_errno;
  44. -    char tbuf[2048], fmt_cpy[1024], *stdp;
  45. +#define TBUFSIZ 2048
  46. +#define FMTSIZ  1024
  47. +    char tbuf[TBUFSIZ+3], fmt_cpy[FMTSIZ+1], *stdp;
  48.  
  49.      saved_errno = errno;
  50.  
  51. @@ -118,7 +120,7 @@
  52.  
  53.      /* Build the message. */
  54.      (void)time(&now);
  55. -    (void)sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4);
  56. +    (void)snprintf(tbuf, TBUFSIZ, "<%d>%.15s ", pri, ctime(&now) + 4);
  57.      for (p = tbuf; *p; ++p);
  58.      if (LogStat & LOG_PERROR)
  59.          stdp = p;
  60. @@ -127,7 +129,7 @@
  61.          for (; *p; ++p);
  62.      }
  63.      if (LogStat & LOG_PID) {
  64. -        (void)sprintf(p, "[%d]", getpid());
  65. +        (void)snprintf(p, TBUFSIZ-(p-tbuf), "[%d]", getpid());
  66.          for (; *p; ++p);
  67.      }
  68.      if (LogTag) {
  69. @@ -137,20 +139,21 @@
  70.  
  71.      /* Substitute error message for %m. */
  72.      {
  73. -        register char ch, *t1, *t2;
  74. +        register char ch, *t1;
  75.          char *strerror();
  76.  
  77. -        for (t1 = fmt_cpy; ch = *fmt; ++fmt)
  78. +        for (t1 = fmt_cpy; (ch = *fmt) != '\0' && t1<fmt_cpy+FMTSIZ; ++fmt)
  79.              if (ch == '%' && fmt[1] == 'm') {
  80.                  ++fmt;
  81. -                t1 += sprintf(t1, "%s", strerror(saved_errno));
  82. +                t1 += snprintf(t1, FMTSIZ-(t1-fmt_cpy),
  83. +                           "%s", strerror(saved_errno));
  84.              }
  85.              else
  86.                  *t1++ = ch;
  87.          *t1 = '\0';
  88.      }
  89.  
  90. -    p += vsprintf(p, fmt_cpy, ap);
  91. +    p += vsnprintf(p, TBUFSIZ-(p-tbuf), fmt_cpy, ap);
  92.      cnt = p - tbuf;
  93.  
  94.      /* Output to stderr if requested. */
  95. @@ -175,7 +178,7 @@
  96.      }
  97.      else
  98.      {
  99. -        /* If the write fails, we try to reconect it next
  100. +        /* If the write fails, we try to reconnect it next
  101.           * time. */
  102.          closelog ();
  103.      }
  104.